

#ifndef __LH_WIDGET_H__
#define __LH_WIDGET_H__

#include "lh_include.h"

#define LH_FILE_NULL    ""  
#define LH_GET_WIDNUM(a) (sizeof(a) / sizeof(a[0]))
typedef void LH_WIDEV(void *wiget);
typedef void LH_CALLBACK(LH_U16 widseq);


enum
{
    FATHER_NULL = 0,
    DIALOG_0, DIALOG_1, DIALOG_2, DIALOG_3, DIALOG_4, DIALOG_5, DIALOG_6, DIALOG_7, DIALOG_8, DIALOG_9, DIALOG_10, 
    BUTTON_0, BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5, BUTTON_6, BUTTON_7, BUTTON_8, BUTTON_9, BUTTON_10,
    LABEL_0,  LABEL_1,  LABEL_2,  LABEL_3,  LABEL_4,  LABEL_5,  LABEL_6,  LABEL_7,  LABEL_8,  LABEL_9,  LABEL_10,
    RADIO_0,  RADIO_1,  RADIO_2,  RADIO_3,  RADIO_4,  RADIO_5,  RADIO_6,  RADIO_7,  RADIO_8,  RADIO_9,  RADIO_10,
    GRAPH_0,  GRAPH_1,  GRAPH_2,  GRAPH_3,  GRAPH_4,  GRAPH_5,  GRAPH_6,  GRAPH_7,  GRAPH_8,  GRAPH_9,  GRAPH_10,
    EDIT_0,   TEXT_1,   EDIT_2,   EDIT_3,   EDIT_4,   EDIT_5,   EDIT_6,   EDIT_7,   EDIT_8,   EDIT_9,   EDIT_10,
    MULTIEDIT_0, MULTIEDIT_1, MULTIEDIT_2, MULTIEDIT_3, MULTIEDIT_4, MULTIEDIT_5, MULTIEDIT_6, MULTIEDIT_7, MULTIEDIT_8, MULTIEDIT_9, MULTIEDIT_10,
};


#define     LH_WIDREEV      ((uint16_t)0x0001)      
#define     LH_CLDWID       ((uint16_t)0x0002)      
#define     LH_WIDFOC       ((uint16_t)0x0004)      
#define     LH_CLDFOC       ((uint16_t)0x0008)      
#define     LH_WIDREDR      ((uint16_t)0x0010)      
#define     LH_WIDBUD       ((uint16_t)0x0020)      
#define     LH_BUDREDR      ((uint16_t)0x0040)      
#define     LH_CACHMOVDG    ((uint16_t)0x0080)      
#define     LH_CACHMOVCD    ((uint16_t)0x0100)      
#define     LH_SHOWHC       ((uint16_t)0x0200)      


enum
{
    LH_WID_NULL = 0,        
    LH_WID_OCCUPY,          
    LH_DIALOG,              
    LH_BUTTON,              
    LH_LABEL,               
    LH_RADIO,               
    LH_GRAPH,               
    LH_EDIT,                
    LH_MULTIEDIT,            
};   


typedef struct WIDGET
{
    LH_U16  FatherWidSeq;       
    LH_U8   WidgetType;         
    LH_U16  DialogLayer;        
    LH_S16  Axis_X;             
    LH_S16  Axis_Y;             
    LH_U16  Length;             
    LH_U16  Width;              
    LH_U8   WidSeq;             
    LH_WIDEV *WidEv;            
    LH_CALLBACK *CallBack;      
    LH_U16  WidColor;           
    LH_U16  WidFont;            
    void    *PData;             
    LH_C8   *Path1;             
    LH_C8   *Path2;             
    LH_U16  WidFlags;           
                                
                                
    struct WIDGET *LastWidget;  
    struct WIDGET *NextWidget;  
}LH_WIDGET; 


typedef struct 
{
    LH_U8   WidgetType;         
    LH_S16  Axis_X;             
    LH_S16  Axis_Y;             
    LH_U8   WidSeq;             
    void    *PData;             
    LH_C8   *Path1;             
    LH_C8   *Path2;             
    LH_U16  WidFlags;           
                                
                                
}WID_GATHER; 

extern LH_U16   LH_GUIRunEve;   


void FreeLHDialogBuff(LH_WIDGET *dialog);
LH_WIDGET *LH_CreatDialog(WID_GATHER *widgather, LH_U16 widnum, LH_CALLBACK *callback);
void LH_MemWidAllot(LH_WIDGET *widget, WID_GATHER *widgather);
void LH_WidEvAssign(LH_WIDGET *widget);
void LH_WidgetScan(void);
LH_WIDGET *GetTocDig(LH_WIDGET *dialog);
LH_WIDGET *GetChildFather(LH_WIDGET *child);
LH_WIDGET *GetDialogWid(LH_WIDGET *dialog, LH_U16 WidSeq);
void SetWidgetRedraw(LH_WIDGET *widget);
void CleanWidgetRedraw(LH_WIDGET *widget);
void SetWidgetWidReEv(LH_WIDGET *widget);
void CleanWidgetWidReEv(LH_WIDGET *widget);
void SetWidTopRedraw(LH_WIDGET *widget);
void SetFormRedraw(LH_WIDGET *widget);
void CleanFormRedraw(LH_WIDGET *widget);
void RedrawCrAnNeWid(LH_WIDGET *widget);
void LH_SetWidgetFocus(LH_WIDGET *widget);


void SetWidColor(LH_WIDGET *widget, LH_U16 color);
LH_U16 GetWidColor(LH_WIDGET *widget);
void SetStrWidPData(LH_WIDGET *widget, LH_S8 *pbuff);
void SetPDataInt(LH_WIDGET *widget, LH_U64 num, LH_U16 leng, LH_U16 dotp);


void LH_DialogEve(void *widget);

void LH_ButtonEve(void *widget);

void LH_LabelEve(void *widget);

void LH_RadioEve(void *widget);
void FourBoundRadio(LH_WIDGET *Dialog, LH_U8 WidSeq1, LH_U8 WidSeq2, LH_U8 WidSeq3, LH_U8 WidSeq4);
void TowBoundRadio(LH_WIDGET *Dialog, LH_U8 WidSeq1, LH_U8 WidSeq2);
LH_U16 CheckRdiBudReDr(LH_WIDGET *Dialog, LH_U8 WidSeq);

void LH_GraphEve(void *widget);
void GraphPdataInit(LH_WIDGET *graph);
void GraphSetOrigXY(LH_WIDGET *graph, LH_U16 origx, LH_U16 origy);
void GraphSetUnitSize(LH_WIDGET *graph, LH_U16 unitsize);
void GraphAddData(LH_WIDGET *graph, LH_U16 data);
void SetGraphFirstDra(LH_WIDGET *graph);

void LH_EditEve(void *widget);

void LH_MultiEditEve(void *widget);
void LH_MultiEditAdd(LH_WIDGET *widget, LH_S8 *str);


LH_S8 *GetS8Unit(LH_WIDGET *widget);
void FreeS8Unit(LH_WIDGET *widget);
LH_S8 *GetS8TextUnit(LH_WIDGET *widget);
void FreeS8TextUnit(LH_WIDGET *widget);
LH_S16 *GetS16Unit(LH_WIDGET *widget);
void FreeS16Unit(LH_WIDGET *widget);
LH_WIDGET *GetWidBuffUnit(void);
void FreeWidBuffUnit(LH_WIDGET *widget);

#endif



